<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">

<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span>印章返还</span><div class="move_title"></div><?php include "../public/sub.php";?></div></div>
    <div class="main-container">

        <div class="block-generic">


            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>基本信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">印章名称</label>
                        <div class="layui-input-block">
                            <input type="text" id="sealname" readonly  placeholder="请输入" clearable  autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>是否返还</label>
                        <div class="layui-input-block">
                            <select id="isfan" name="isfan" lay-filter="isfan" >
                                <option value="">请选择</option>
                                <option value="1">是</option>
                                <option value="0">否</option>
                            </select>
                            <p class="error" id="isfan_error" style="margin: 0;"></p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">实际返还时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="fandt" id="fandt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymdhi">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">接收人</label>
                        <div class="layui-input-block">
                            <input type="text" name="faner" id="faner" placeholder="请输入" clearable  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
        </div>


    </div>
</form>
<script>
    var param_id = getQueryVariable('id') || 0;

    $("#commentForm").validate({
        rules: {
            fandt: {required: true},
            faner: {required: true},
        },
        messages:{
            fandt: {required: "请选择"},
            faner: {required: "请输入"},
        }
    });

    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();

        facade.ajax({type: 'get', url: ask_seal_wai_fan, data:{id:param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;
                $("#sealname").val(data.sealname);
                $("#isfan").val(data.isfan);
                $("#fandt").val(data.fandt);
                $("#faner").val(data.faner);

                render_from();
                initParseMoney();
            }
        });



        form.on('select(isfan)', function(data){
            if(data.value == ''){
                $('#isfan_error').show().text('请选择');
                $('#isfan_error').parent().find('input').addClass('select_error');
            }else{
                $('#isfan_error').hide();
                $('#isfan_error').parent().find('input').removeClass('select_error');
            }
        });

        form.on('submit(add)', function(data){
            parseMoney(data);
            var validRes = $("#commentForm").valid();

            if(data.field.isfan == ''){
                $('#isfan_error').show().text('请选择');
                $('#isfan_error').parent().find('input').addClass('select_error');
                validRes = false;
            }else{
                $('#isfan_error').hide();
                $('#isfan_error').parent().find('input').removeClass('select_error');
            }

            if(!validRes){return false;}




            data.field.id = param_id;
            data = parseMoney(data);
            facade.ajax({url: ask_seal_wai_fan, data:data.field}).done(function(res){
                if (res.code === 2000) {
                    dataPostTimeOut();
                }
            });

            return false;
        });

    });


</script>
</body>
</html>
